# Maintainer: Felix Xing (Felixaszx) <felixaszx@outlook.com>

_realname=vk-bootstrap
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.313
pkgrel=1
pkgdesc="A utility library that jump starts initialization of Vulkan (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://charles-lunarg.github.io/vk-bootstrap/"
msys2_repository_url="https://github.com/charles-lunarg/vk-bootstrap"
license=("spdx:MIT")
depends=("${MINGW_PACKAGE_PREFIX}-vulkan-headers")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("https://github.com/charles-lunarg/vk-bootstrap/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('7156af11e175dee54e371bdd566af0b98ca90cd1fd92f034af2aa7ae8ad689ec')

build() {
  declare -a extra_config
  if check_option "debug" "n"; then
    extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

# For some reasons -DBUILD_SHARED_LIBS=ONs does not work, it will only build static lib
# This is an upstream issue
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    cmake \
      -GNinja \
      -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
      -DBUILD_SHARED_LIBS=ON \
      -DVK_BOOTSTRAP_TEST=OFF \
      "${extra_config[@]}" \
      -S "${_realname}-${pkgver}" \
      -B "build-${MSYSTEM}"

  cmake --build "build-${MSYSTEM}"
}

package() {
  DESTDIR="${pkgdir}" cmake --install "build-${MSYSTEM}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.txt" \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
